import 'package:finance_app/src/entities/batch_invenotries_entity.dart';

batchInvenotriesEntityFromJson(BatchInvenotriesEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['inventoriable_type'] != null) {
		data.inventoriableType = json['inventoriable_type'].toString();
	}
	if (json['inventoriable_id'] != null) {
		data.inventoriableId = json['inventoriable_id'] is String
				? int.tryParse(json['inventoriable_id'])
				: json['inventoriable_id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['type_id'] != null) {
		data.typeId = json['type_id'];
	}
	if (json['quantity'] != null) {
		data.quantity = json['quantity'] is String
				? int.tryParse(json['quantity'])
				: json['quantity'].toInt();
	}
	if (json['inventory_left'] != null) {
		data.inventoryLeft = json['inventory_left'] is String
				? int.tryParse(json['inventory_left'])
				: json['inventory_left'].toInt();
	}
	if (json['notes'] != null) {
		data.notes = json['notes'];
	}
	if (json['batch'] != null) {
		data.batch = json['batch'].toString();
	}
	if (json['created_by'] != null) {
		data.createdBy = json['created_by'];
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['entity_name'] != null) {
		data.entityName = json['entity_name'].toString();
	}
	return data;
}

Map<String, dynamic> batchInvenotriesEntityToJson(BatchInvenotriesEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['inventoriable_type'] = entity.inventoriableType;
	data['inventoriable_id'] = entity.inventoriableId;
	data['name'] = entity.name;
	data['type'] = entity.type;
	data['type_id'] = entity.typeId;
	data['quantity'] = entity.quantity;
	data['inventory_left'] = entity.inventoryLeft;
	data['notes'] = entity.notes;
	data['batch'] = entity.batch;
	data['created_by'] = entity.createdBy;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['entity_name'] = entity.entityName;
	return data;
}